package com.ruoyi.shop.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.shop.domain.vo.ProductCategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shop.mapper.ShopProductCategoryMapper;
import com.ruoyi.shop.domain.ShopProductCategory;
import com.ruoyi.shop.service.IShopProductCategoryService;
import com.ruoyi.common.core.text.Convert;

/**
 * 商品分类。标签、专题、类别等都属于category。Service业务层处理
 * 
 * @author Alan Zhang
 * @date 2021-09-12
 */
@Service
public class ShopProductCategoryServiceImpl implements IShopProductCategoryService 
{
    @Autowired
    private ShopProductCategoryMapper shopProductCategoryMapper;

    /**
     * 查询商品分类。标签、专题、类别等都属于category。
     * 
     * @param id 商品分类。标签、专题、类别等都属于category。主键
     * @return 商品分类。标签、专题、类别等都属于category。
     */
    @Override
    public ShopProductCategory selectShopProductCategoryById(Long id)
    {
        return shopProductCategoryMapper.selectShopProductCategoryById(id);
    }

    /**
     * 查询商品分类。标签、专题、类别等都属于category。列表
     * 
     * @param shopProductCategory 商品分类。标签、专题、类别等都属于category。
     * @return 商品分类。标签、专题、类别等都属于category。
     */
    @Override
    public List<ShopProductCategory> selectShopProductCategoryList(ShopProductCategory shopProductCategory)
    {
        return shopProductCategoryMapper.selectShopProductCategoryList(shopProductCategory);
    }

    /**
     * 新增商品分类。标签、专题、类别等都属于category。
     * 
     * @param shopProductCategory 商品分类。标签、专题、类别等都属于category。
     * @return 结果
     */
    @Override
    public int insertShopProductCategory(ShopProductCategory shopProductCategory)
    {
        shopProductCategory.setCreateTime(DateUtils.getNowDate());
        return shopProductCategoryMapper.insertShopProductCategory(shopProductCategory);
    }

    /**
     * 修改商品分类。标签、专题、类别等都属于category。
     * 
     * @param shopProductCategory 商品分类。标签、专题、类别等都属于category。
     * @return 结果
     */
    @Override
    public int updateShopProductCategory(ShopProductCategory shopProductCategory)
    {
        shopProductCategory.setUpdateTime(DateUtils.getNowDate());
        return shopProductCategoryMapper.updateShopProductCategory(shopProductCategory);
    }

    /**
     * 批量删除商品分类。标签、专题、类别等都属于category。
     * 
     * @param ids 需要删除的商品分类。标签、专题、类别等都属于category。主键
     * @return 结果
     */
    @Override
    public int deleteShopProductCategoryByIds(String ids)
    {
        return shopProductCategoryMapper.deleteShopProductCategoryByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商品分类。标签、专题、类别等都属于category。信息
     * 
     * @param id 商品分类。标签、专题、类别等都属于category。主键
     * @return 结果
     */
    @Override
    public int deleteShopProductCategoryById(Long id)
    {
        return shopProductCategoryMapper.deleteShopProductCategoryById(id);
    }


    /**
     * 查询分类名称是否存在
     * @param name
     * @return
     */
    @Override
    public Long selectShopProductCategoryByName(String name){
        return shopProductCategoryMapper.selectShopProductCategoryByName(name);
    }

    /**
     * 全部分类 id 名称
     * @return
     */
    @Override
    public List<ProductCategoryVo> selectSimpleShopProductCategoryAll(){
        return shopProductCategoryMapper.selectSimpleShopProductCategoryAll();
    }
}
